package org.apogee.mil.client.main.pages.admin.forms.widgets;

import org.apogee.mil.client.main.pages.admin.forms.AddUser;
import org.apogee.mil.client.main.pages.admin.forms.AdminUserForm;
import org.apogee.mil.client.main.pages.admin.forms.AdminUserScore;
import org.apogee.mil.client.widgets.DialogHelper;

import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;

public class UserOptions implements IsWidget {

	@Override
	public Widget asWidget() {
		ContentPanel cp = new ContentPanel();
		cp.setHeading("User Options");
		cp.setBorders(true);
		
		HorizontalPanel hp = new HorizontalPanel();
		
		
		Button button = new Button("Add User");
		button.setStyleAttribute("padding", "10px");
		button.setWidth(150);
		button.addSelectionListener(new SelectionListener<ButtonEvent>() {
			
			@Override
			public void componentSelected(ButtonEvent ce) {
				DialogHelper helper = new DialogHelper("Add User", new AddUser());
				helper.show();
			}
		});
		
		hp.add(button);
		
		
		button = new Button("User Maintenance");
		button.setStyleAttribute("padding", "10px");
		button.setWidth(150);
		button.addSelectionListener(new SelectionListener<ButtonEvent>() {
			
			@Override
			public void componentSelected(ButtonEvent ce) {
				DialogHelper helper = new DialogHelper("User Maintenance", new AdminUserForm());
				helper.show();
			}
		});
		
		hp.add(button);
		cp.add(hp);
		
		
		hp = new HorizontalPanel();
		cp.add(hp);
		
		button = new Button("View Users Scores");
		button.setStyleAttribute("padding", "10px");
		button.setWidth(150);
		button.addSelectionListener(new SelectionListener<ButtonEvent>() {
			
			@Override
			public void componentSelected(ButtonEvent ce) {
				DialogHelper helper = new DialogHelper("User Scores", new AdminUserScore().asWidget());
				helper.show();
			}
		});
		
		hp.add(button);
		
		return cp;
	}

}
